import numpy as np

"""
    多维数组和矩阵的关系：
    
    [n个元素] ：  n行    shape(n,)
    [[m个元素]] ：m列    shape（1,m）
    
    
    对应行、列位置之积的和
    矩阵的(1,1)元素  = 第一行第n个 * 第一列第n个 之和
"""
if __name__ == "__main__":
    var1 = np.linspace(-0.5, 0.5, 2)
    var2 = np.eye(2, 2)
    var3 = var1[:, None]
    print(np.random.uniform(0, 12, 20))
    print(var2, var2.shape)
    print(var1, var1.shape)
    print(var3, var3.shape)

    a = np.array([1, 2])
    a1 = np.mat(a)
    a2 = np.mat([[2], [4]])
    print("a1 @ a2", a1 @ a2)
    print("a1 @ a2", np.dot(a1, a2))

    # 2-D array: 2 x 3
    two_dim_matrix_one = np.array([[1, 2, 3], [4, 5, 6]])
    # 2-D array: 3 x 2
    two_dim_matrix_two = np.array([[1, 2], [3, 4], [5, 6]])

    two_multi_res = np.dot(two_dim_matrix_one, two_dim_matrix_two)
    print('two_multi_res: %s' % (two_multi_res))
    print(two_dim_matrix_two.shape, two_dim_matrix_two.shape)
